package com.topwalk.datacollect.enumI;

import org.springframework.util.StringUtils;

public enum FactoryEnum {
    SERVER("server");

    private String factoryCode;

    private FactoryEnum(String factoryCode){
        this.factoryCode = factoryCode;
    }

    private String getFactoryCode() {
        return factoryCode;
    }

    public static FactoryEnum getTypeByValue(String factoryCode){
        if(StringUtils.isEmpty(factoryCode)){
            throw new IllegalArgumentException("参数不能为空");
        }

        for(FactoryEnum factoryEnum : FactoryEnum.values()){
            if(factoryEnum.getFactoryCode().equalsIgnoreCase(factoryCode)){
                return factoryEnum;
            }
        }

        throw new IllegalArgumentException("未找到factory类型："+factoryCode);
    }



}
